package com.example.learn_android;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import org.w3c.dom.Text;

public class ButtonIsEnable extends Activity implements View.OnClickListener {
    Button btn_isEnable;
    TextView text;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button_is_enable);
        Button btn_enable = findViewById(R.id.btnEnable);
        Button btn_disable = findViewById(R.id.btnDisable);
        btn_isEnable = findViewById(R.id.btnIsEnable);
        text = findViewById(R.id.enableResult);
        btn_enable.setOnClickListener(this);
        btn_disable.setOnClickListener(this);
        btn_isEnable.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btnEnable) {
            btn_isEnable.setEnabled(true);
            btn_isEnable.setTextColor(Color.BLACK);
        } else if (v.getId() == R.id.btnDisable) {
            btn_isEnable.setEnabled(false);
            btn_isEnable.setTextColor(Color.GRAY);
        } else if (v.getId() == R.id.btnIsEnable) {
            text.setText("更改显示内容");
        }
    }
}